Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tabled/ Add Content locator ByContent #367

Merged
merged 13 commits into from
Oct 31, 2023
Merged

Conversation

zhiburt
Copy link
Owner

@zhiburt zhiburt commented Oct 30, 2023

ref #365

todo: tests
todo: ByCondition ... (change the name?)
todo: Maybe create a abstract factory to create locators, e.g. Locator::content(), Locator::condition(), Locator::column()


Just letting you @wbuck know that with it you can do the following.

let data = vec![
Job::new("C Developer", JobStatus::Open),
Job::new("Rust Developer", JobStatus::Closed),
Job::new("Kernel Developer", JobStatus::Open),
];
let color_open_jobs = Color::BG_WHITE | Color::FG_BLACK;
let color_closed_jobs = Color::BG_GREEN | Color::FG_BLACK;
let mut table = Table::new(data);
table
.with(Style::empty())
.with(Modify::list(ByContent::new("open"), color_open_jobs))
.with(Modify::list(ByContent::new("closed"), color_closed_jobs));
println!("{table}");

In your case something like a bellow example.

let ok_color = ...;
let cells_if_status_is_ok = Columns::single(2).and(ByContent::new("UP"));
Modify::new(cells_if_status_is_ok).with(ok_color);

@zhiburt zhiburt merged commit 604a4c8 into master Oct 31, 2023
79 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant